<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>垂直左右居中-flex</title>
    <style>
        .box1 {
            background-color: #f99;
            width: 400px;
            height: 400px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .box2 {
            
            background-color: red;
            width: 100px;
            height: 100px;


        }

    </style>
</head>

<body>

    <div class="box1">
        <div class="box2"></div>
    </div>


</body>

</html>